# uncompyle6 version 3.2.3
# Python bytecode 3.6 (3379)
# Decompiled from: Python 3.6.8 |Anaconda custom (64-bit)| (default, Feb 21 2019, 18:30:04) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: site-packages\macholib\framework.py
"""
Generic framework path manipulation
"""
import re

__all__ = ["framework_info"]
_STRICT_FRAMEWORK_RE = re.compile(
    "(?x)\n(?P<location>^.*)(?:^|/)\n(?P<name>\n    (?P<shortname>[-_A-Za-z0-9]+).framework/\n    (?:Versions/(?P<version>[^/]+)/)?\n    (?P=shortname)\n    (?:_(?P<suffix>[^_]+))?\n)$\n"
)


def framework_info(filename):
    """
    A framework name can take one of the following four forms:
        Location/Name.framework/Versions/SomeVersion/Name_Suffix
        Location/Name.framework/Versions/SomeVersion/Name
        Location/Name.framework/Name_Suffix
        Location/Name.framework/Name
    
    returns None if not found, or a mapping equivalent to:
        dict(
            location='Location',
            name='Name.framework/Versions/SomeVersion/Name_Suffix',
            shortname='Name',
            version='SomeVersion',
            suffix='Suffix',
        )
    
    Note that SomeVersion and Suffix are optional and may be None
    if not present
    """
    is_framework = _STRICT_FRAMEWORK_RE.match(filename)
    if not is_framework:
        return
    else:
        return is_framework.groupdict()
